import axios from "axios";
import Load from './load'
let loading = new Load()
const request = axios.create({
    baseURL: 'https://www.codeman.ink/api',
    timeout: 8000,
    withCredentials: true
})

request.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';

request.interceptors.request.use(config => {
    loading.show()
    return config
}, err => {
    loading.hide()
    return Promise.reject(err)
})

request.interceptors.response.use(config => {
    loading.hide()
    return config.data
}, err => {
    loading.hide()
    return Promise.reject(err);
})


export default request